﻿<Window x:Class="CPPEI.Coolzon.Designer.Views.DataSourcePreview"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:local="clr-namespace:CPPEI.Coolzon.Designer.Views"
        xmlns:design="clr-namespace:CPPEI.Coolzon.ServiceProxy.DesignServiceRef;assembly=CPPEI.Coolzon.ServiceProxy"
        mc:Ignorable="d"
        Title="数据源预览" Height="600" Width="800" WindowStartupLocation="CenterScreen"  Loaded="Window_Loaded" Closing="Window_Closing"  Style="{DynamicResource WindowStyle}">
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>
        <Grid Grid.Row="0" MinHeight="260">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto" MinWidth="120" MaxWidth="240"/>
                <ColumnDefinition Width="Auto" MinWidth="120" MaxWidth="240"/>
                <ColumnDefinition Width="*" MinWidth="240"/>
            </Grid.ColumnDefinitions>
            <GroupBox Grid.Column="0" Header="数据源" >
                <Grid>
                    <TextBlock x:Name="_ctltbDataSource" Text="正在加载数据源..." Visibility="Visible"/>
                    <TextBlock x:Name="_ctlRetry" Visibility="Collapsed">
                        <Hyperlink Click="Hyperlink_Click">
                            加载失败,重试...
                        </Hyperlink>
                    </TextBlock>
                    <ListView x:Name="_ctlDataSource" Visibility="Collapsed" SelectionChanged="_ctlDataSource_SelectionChanged" MaxWidth="238" Margin="2" ScrollViewer.VerticalScrollBarVisibility="Auto" ScrollViewer.HorizontalScrollBarVisibility="Auto"  >
                        <ListView.ItemTemplate>
                            <HierarchicalDataTemplate DataType="{x:Type design:PublishedDataSource}">
                                <TextBlock Text="{Binding Name}" Margin="2,2,10,2" ToolTip="{Binding Caption}"/>
                            </HierarchicalDataTemplate>
                        </ListView.ItemTemplate>
                    </ListView>
                </Grid>
            </GroupBox>
            <GroupBox Grid.Column="1" Header="数据集" >
                <ListView x:Name="_ctlDataSet" SelectionChanged="_ctlDataSet_SelectionChanged" MaxWidth="238" ScrollViewer.VerticalScrollBarVisibility="Auto" ScrollViewer.HorizontalScrollBarVisibility="Auto"  Margin="2"   >
                    <ListView.ItemTemplate>
                        <HierarchicalDataTemplate DataType="{x:Type design:DataSet}">
                            <TextBlock Text="{Binding Name}" Margin="2,2,10,2" ToolTip="{Binding Caption}"/>
                        </HierarchicalDataTemplate>
                    </ListView.ItemTemplate>
                </ListView>
            </GroupBox>
            <GroupBox Grid.Column="2" Header="参数" MinWidth="240"   Margin="2">
                <Grid Name="_ctlParams" ScrollViewer.VerticalScrollBarVisibility="Auto" ScrollViewer.HorizontalScrollBarVisibility="Auto" >
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="Auto"/>
                        <ColumnDefinition Width="*"/>
                    </Grid.ColumnDefinitions>
                </Grid>
            </GroupBox>
        </Grid>
        <GridSplitter BorderBrush="Gray" BorderThickness="1" Width="5" Grid.Row="0" VerticalAlignment="Stretch" HorizontalAlignment="Right"/>
        <StackPanel Style="{DynamicResource ButtonPanelBackground}" x:Name="_ctlSP" Grid.Row="1" Orientation="Horizontal" MinHeight="23">
            <Button Style="{DynamicResource  SubmitOrCancelButtonStyle}" Content="预览" Width="75" Margin="3" Click="Button_Click" />
        </StackPanel>
        <DataGrid x:Name="_ctlDataGrid" Grid.Row="2" MinHeight="260" AutoGenerateColumns="False" MaxHeight="500" IsReadOnly="True">
            <DataGrid.Columns>
                <DataGridTextColumn Header="串ID" Width="Auto" Binding="{Binding SeriesID}"></DataGridTextColumn>
                <DataGridTextColumn Header="串名称" Width="Auto" Binding="{Binding SeriesName}"></DataGridTextColumn>
                <DataGridTextColumn Header="项ID" Width="Auto" Binding="{Binding ItemID}"></DataGridTextColumn>
                <DataGridTextColumn Header="项名称" Width="Auto" Binding="{Binding ItemName}"></DataGridTextColumn>
                <DataGridTextColumn Header="值" Width="Auto" Binding="{Binding Value}"></DataGridTextColumn>
            </DataGrid.Columns>
        </DataGrid>
    </Grid>
</Window>
